package com.balakitbbs.controller;

import org.springframework.beans.factory.annotation.Autowired; 
import java.util.*;               
import org.springframework.stereotype.Controller;               
import org.springframework.web.bind.annotation.PathVariable;               
import org.springframework.web.bind.annotation.RequestMapping;               
import org.springframework.web.servlet.ModelAndView;               
import com.balakitbbs.page.Page;               
import com.balakitbbs.page.SearchPageUtil;               
import com.balakitbbs.service.Bala_mainpostService;
import com.balakitbbs.entity.Bala_mainpost;
   /**
    * bala_mainpost Controller类
    */ 
@Controller
public class Bala_mainpostController{
	@Autowired
	private Bala_mainpostService bala_mainpostservice;

//增加主贴表
@RequestMapping("/page/{pageIndex}/{pageSize}/addBala_mainpost")
public String addBala_mainpost(Bala_mainpost bala_mainpost,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_mainpost.setCdate(new Date());
	bala_mainpost.setId(UUID.randomUUID().toString());
	bala_mainpostservice.addBala_mainpost(bala_mainpost);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_mainpost.do";
}


//删除主贴表
@RequestMapping("/page/{Id}/{pageIndex}/{pageSize}/delBala_mainpost")
public String delBala_mainpost(@PathVariable String Id,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_mainpostservice.delBala_mainpost(Id);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_mainpost.do";
}


//修改主贴表
@RequestMapping("/page/{pageIndex}/{pageSize}/updateBala_mainpost")
public String updateBala_mainpost(Bala_mainpost bala_mainpost,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_mainpost.setUdate(new Date());
	bala_mainpostservice.updateBala_mainpost(bala_mainpost);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_mainpost.do";
}


//查询主贴表
@RequestMapping("/page/{pageIndex}/{pageSize}/selectBala_mainpost")
public ModelAndView selectBala_mainposts(Bala_mainpost bala_mainpost,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	ModelAndView modelAndView = new ModelAndView();
	int selectBala_mainpostCount = bala_mainpostservice.selectBala_mainpostsByPOJOCount(bala_mainpost);
	Page page = new Page(pageIndex, pageSize, selectBala_mainpostCount);
	SearchPageUtil spu = new SearchPageUtil();
	spu.setPage(page);
	modelAndView.addObject("data", bala_mainpostservice.selectBala_mainpostsByPojoPage(spu, bala_mainpost));
	modelAndView.addObject("page", page);
	modelAndView.addObject("s", 1);
	modelAndView.addObject("po", new Bala_mainpost());
	modelAndView.setViewName("/WEB-INF/page/bala_mainpost.jsp");
	return modelAndView;
}

}

